<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 引入vue.js  -->
    <script src="../node_modules/vue/dist/vue.js"></script>
    <style>
        .active {
            color: green;
        }
        .delete {
            background-color: red;
        }
        .error {
            font-size: 30px;
        }
    </style>
</head>
<body>
    <!-- #app id为app的div -->
    <div id="app">
        <h2>class值绑定, v-bind:class 或 :class</h2>
        <p v-bind:class="activeClass">字符串表达式</p>

        <p :class="activeClass">对象表达式</p>
        <p :class="{ delete: true, error: true}">对象表达式</p>
        <p :class="{ delete: isDelete, error: hasError}">对象表达式</p>
    </div>

    <script>
        // 实例化vuejs应用
        var vm = new Vue({
            el: "#app",
            data: {
                activeClass: 'active',
                isDelete: true,
                hasError: false,
            },
            mounted() {
                console.log({ delete: this.isDelete, error: this.hasError})
            }
        })
    </script>
</body>
</html>